import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dings
 * Date: 2024-07-13
 * Time: 11:15
 */
public class Test {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        ArrayList<Integer> list2 = new ArrayList<>();
        list2.add(11);
        list2.add(11);
        list.add(1);
        list.addAll(list2);
        list.add(1);

        System.out.println(list.size());
    }
    /*public int getLeafNodeCount(TreeNode root) {
        if(root.left == null && root.right == null) {
            return 1;
        }
        return getLeafNodeCount(root.left) + getLeafNodeCount(root.right);
    }


    public void getLeafNodeCount2(TreeNode root) {
        if (root == null) {
            return;
        }
        if(root.left == null && root.right == null) {
            leftNode++;
        }
        getLeafNodeCount(root.left);
        getLeafNodeCount(root.right);
    }

    while(k != 1) {

        k--;
    }
    getK(root.left);
    getK(root.right);*/


    //求节点个数
    public int size(TreeNode root) {
        if(root == null) {
            return 0;
        }
        int leftN = size(root.left);
        int rightN = size(root.right);

        return leftN + rightN + 1;
    }


    //求叶子节点个数 子问题求解
    public int getLeafCount1(TreeNode root) {
        if(root == null) {
            return 0;
        }
        if(root.next == null && root.right == null) {
            return 1;
        }
        int leftLeafN = size(root.left);
        int rightLeafN = size(root.right);

        return leftLeafN + rightLeafN;
    }

    public static int leaf;
    //求节点个数 遍历求解
    public void getLeafCount2(TreeNode root) {
        if(root == null) {
            return;
        }
        if(root.next == null && root.right == null) {
            leaf++;
        }
        size(root.left);
        size(root.right);
    }

    public int getKLevelCount(TreeNode root,int k) {
        if (root == null) {
            return 0;
        }
        if (k != 1) {
            return getKLevelCount(root.left,k-1) + getKLevelCount(root.right,k-1);
        }else {
            return 1;
        }
    }


    public TreeNode findVal(TreeNode root,int val) {
        if (root == null) {
            return null;
        }
        if (root.val == val) {
            return root;
        }
        TreeNode node = findVal(root.left,val);
        if (node != null) {
            return node;
        }
        TreeNode node1 = findVal(root.right,val);
        if (node1 != null) {
            return node1;
        }
        return null;
    }
}
